home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 02 Useful Techniques / 08 Zarozinski / src / ffllapi / COGDefuzzSetObj.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-12-01  |  2.1 KB  |  82 lines

  1. //
  2. // File:    COGDefuzzSetObj.h
  3. //
  4. // Purpose:    Mean of Maximum defuzzification Method.
  5. //
  6. // Copyright ⌐ 2001 Louder Than A Bomb! Software
  7. //
  8. // This file is part of the FFLL (Free Fuzzy Logic Library) project (http://ffll.sourceforge.net)
  9. // It is released under the BSD license, see http://ffll.sourceforge.net/license.txt for the full text.
  10. //
  11.  
  12. #ifndef _COGDefuzzSetObj_H
  13. #define _COGDefuzzSetObj_H
  14.  
  15. #include "DefuzzVarObj.h"
  16. #include "DefuzzSetObj.h"
  17. class FuzzyOutSet;
  18.  
  19. // 
  20. // Class:    COGDefuzzSetObj
  21. //
  22. // Defuzz set object for Center of Gravity defuzz method.
  23. // See COGDefuzzVarObj.h for details on this defuzz method
  24. //
  25.  
  26. class   COGDefuzzSetObj : public DefuzzSetObj
  27. {
  28.     ////////////////////////////////////////
  29.     ////////// Member Functions ////////////
  30.     ////////////////////////////////////////
  31.  
  32.     public:
  33.         // constructor/destructor funcs
  34.         COGDefuzzSetObj();// No function body for this. Explicitly disallow auto-creation of it by the compiler
  35.         COGDefuzzSetObj(FuzzyOutSet* par) ;
  36.         virtual ~COGDefuzzSetObj(); 
  37.         int init(int array_max);
  38.  
  39.         // get functions
  40.         int get_defuzz_type() const;
  41.          RealType get_area(int _idx) const;
  42.         RealType get_moment(int _idx) const;
  43.         RealType get_defuzz_x(int dom);
  44.  
  45.         // set functions
  46.          void set_area(int _idx, RealType val);
  47.         void set_moment(int _idx, RealType val);
  48.  
  49.         // misc functions
  50.         void calc(void);
  51.  
  52.     ////////////////////////////////////////
  53.     ////////// Class Variables /////////////
  54.     ////////////////////////////////////////
  55.     private:
  56.  
  57.         // struct to hold COG values for each set.  The set will have
  58.         // an array of these, one for each DOM of the set.  We pre-calc
  59.         // the COG values for each DOM.  This greatly speeds the process
  60.         // cuz all we need to do is know the 'x' value for this set and
  61.         // we have the COG for the set already calculated.
  62.  
  63.         typedef struct _cog_struct_
  64.             {
  65.              RealType            area;    // area for this COG
  66.             RealType            moment;    // area * cog
  67.             } _cog_struct;
  68.  
  69.     protected:
  70.  
  71.         _cog_struct* values;    // array of COG values
  72.     
  73.  
  74.  
  75. }; // end class COGDefuzzSetObj
  76.  
  77. #else
  78.  
  79. class COGDefuzzSetObj;
  80.   
  81. #endif // _COGDefuzzSetObj_H
  82.